package com.woniu.product.client;

import com.woniu.product.client.param.AddProductParam;
import com.woniu.product.client.param.AddSkuParam;
import com.woniu.product.client.param.DeductStockParam;
import com.woniu.product.client.param.RestoreStockParam;
import com.woniu.result.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;


@FeignClient(contextId = "productManageClient", name = "product")
public interface ProductManageClient {


    /**
     * 扣减库存
     *
     * @param deductStockParam
     * @return
     * @throws Exception
     */
    @PutMapping("deductStock")
    public Result deductStock(@RequestBody DeductStockParam deductStockParam) throws Exception;

    /**
     * 还原库存
     *
     * @param restoreStockParam
     * @return
     * @throws Exception
     */
    @PutMapping("restoreStock")
    public Result restoreStock(@RequestBody RestoreStockParam restoreStockParam) throws Exception;

    /**
     * 增加商品spu
     * @param addProduct
     * @return
     */
    @PostMapping("/addProduct")
    public Result addProduct(@RequestBody AddProductParam addProduct);

    /**
     * 增加sku
     * @param addSkuParam
     * @return
     */
    @PostMapping("/addSku")
    public Result addSku(@RequestBody AddSkuParam addSkuParam);

    /**
     * 上传spu的附加文件（如图片）
     * @param file
     * @return
     * @throws IOException
     */
    @PostMapping(value = "/SPUuploadFile",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public Result SPUuploadFile(MultipartFile file) throws IOException;

    /**
     * 上传sku的附件
     * @param file
     * @return
     * @throws IOException
     */
    @PostMapping("/SKUuploadFile")
    public Result SKUuploadFile(MultipartFile file) throws IOException;

    /**
     * sku的上架
     * @param skuId
     * @return
     */
    @GetMapping("upsku")
    public Result upsku(@RequestParam("skuId")Integer skuId);

    /**
     * sku的下架
     * @param skuId
     * @return
     */
    @GetMapping("downSku")
    public Result downsku(@RequestParam("skuId")Integer skuId);

    /**
     * 下架spu
     * @param spuId
     * @return
     */
    @GetMapping("downSPU")
    public Result downSPU(@RequestParam("spuId")Integer spuId);

    /**
     * 上架spu
     * @param spuId
     * @return
     */
    @GetMapping("upSPU")
    public Result upSPU(@RequestParam("spuId")Integer spuId);

    /**
     * 删除spu
     * @param spuId
     * @return
     */
    @GetMapping("delSpu")
    public Result delSPU(@RequestParam("spuId")Integer spuId);

    /**
     * 删除sku
     * @param skuId
     * @return
     */
    @GetMapping("delSku")
    public Result delSku(@RequestParam("skuId")Integer skuId);

    /**
     * 增加销量
     * @param skuId
     * @param count
     * @return
     */
    @PutMapping("addSkuSalesCount")
    public Result addSkuSalesCount(@RequestParam("skuId")Integer skuId,@RequestParam("count")Integer count);


    /**
     * 扣减销量
     * @param skuId
     * @param count
     * @return
     */
    @PutMapping("subtractSkuSalesCount")
    public Result subtractSkuSalesCount(@RequestParam("skuId")Integer skuId,@RequestParam("count")Integer count);

}
